// 云对象教程: https://uniapp.dcloud.net.cn/uniCloud/cloud-obj
// jsdoc语法提示教程：https://ask.dcloud.net.cn/docs/#//ask.dcloud.net.cn/article/129
const db = uniCloud.database();
module.exports = {
	_before: function () { // 通用预处理器
	},
	
	getGoodsByCate(cate_id){
		return db.collection('goods').where({
			category_id: cate_id
		}).get()
	},
	
	async detail(id){
		let result = await db.collection('goods').limit(1).where({
			_id: id
		}).get()
		let ret = {
			affectedDocs: result.affectedDocs,
			data: result.data[0]

		}
		return ret;
	}
}
